package com.qt.socket.tcpwork.work1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Author zsf
 * @Date 2023/10/5 15:27
 * @Version 1.0
 */
public class TcpReceiveTest {

    /**
     * TCP通信练习1 ---多发多收
     * 客户端:多次发送数据
     * 服务器:接收多次接收数据，并打印
     */

    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(8888);
        Socket socket = serverSocket.accept();
        InputStreamReader isr = new InputStreamReader(socket.getInputStream());

        int len;
        while ((len = isr.read()) != -1){
            System.out.print((char)len);
        }

        socket.close();
        serverSocket.close();




    }


}
